﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LGCourt.Logic.BLL;
using LGCourt.Logic.NBL.DBEntities;
using KMFrame.Permission.Util;
using LGCourt.Logic.Common;

namespace lgweb.inside
{
    public partial class login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Session.Clear();
            OA oaBLL = new OA();
            vOAORGInfo orgInfo = oaBLL.GetOrgInfo();
            this.h_rtxinstalled.Value = orgInfo.rtx.GetValueOrDefault(0).ToString();
            this.h_rtxserverip.Value = orgInfo.rtx_app_serverip;
            this.h_rtxserverport.Value = orgInfo.rtx_app_serverport.GetValueOrDefault(8000).ToString();
            this.hdOADomain.Value = System.Configuration.ConfigurationManager.AppSettings["OADomain"];
            if (h_rtxinstalled.Value == "") h_rtxinstalled.Value = "0";
            if (h_rtxserverip.Value == "") h_rtxserverip.Value = this.Request.Url.Authority;
            if (h_rtxserverport.Value == "") h_rtxserverport.Value = "8000";

            if (Request.QueryString["backpathurl"] != null && !string.IsNullOrEmpty(Request.QueryString["backpathurl"].ToString()))
            {
                this.hdnUrl.Value = Request.QueryString["backpathurl"].ToString();
            }

            if (Request.Cookies["userpwd"] != null && !string.IsNullOrEmpty(Request.Cookies["userpwd"].Value.ToString()))
            {
                this.chxup.Checked = true;
                this.txtPassword.Value = Request.Cookies["pd"] == null ? "" : Request.Cookies["pd"].Value.ToString();
                this.txtUserName.Value = Request.Cookies["un"] == null ? "" : Server.UrlDecode(Request.Cookies["un"].Value.ToString());
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
           // int usertype = this.rdocredentials1.Checked ? 0 : this.rdocredentials2.Checked ? 0 : this.rdocredentials3.Checked ? 1 : 0;

            //string sUserName = this.txtUserName.Value;
            //string sPwd = this.txtPassword.Value;

            //OA bll = new OA();

            //vOAUser result = (vOAUser)bll.Login(sUserName, sPwd);

            //if (result != null)
            //{
            //    UserSession user = new UserSession(result.userid, result.username, Guid.Empty);
            //    SessionBox.CreateUserSession(user);

            //    Response.Redirect("/inside/index.aspx");
               
            //}
            //else
            //{
            //    this.spMessage.InnerHtml = "登录失败，请检查用户和密码是否正确，并重新登录！";
            //}

        }
    }
}